home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / expire / histslash.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  695b  |  37 lines

  1. /*
  2.  * Convert slashed filenames to dotted group/article names in a history
  3.  * file, for use in mkhistory.  Input comes only from stdin.
  4.  */
  5. #include <stdio.h>
  6. #include <assert.h>
  7.  
  8. char *progname = "histslash";
  9.  
  10. char buf[4096];            /* paranoia -- ought to be lots */
  11.  
  12. main()
  13. {
  14.     register char *scan;
  15.     register char *last;
  16.     extern char *strchr();
  17.  
  18.     while (fgets(buf, sizeof(buf), stdin) != NULL) {
  19.         scan = strchr(buf, '\t');
  20.         scan = strchr(scan+1, '\t');
  21.         scan++;
  22.         last = NULL;
  23.         while (*scan != '\0') {
  24.             if (*scan == '/') {
  25.                 *scan = '.';
  26.                 last = scan;
  27.             }
  28.             if (*scan == ' ' || *scan == '\n') {
  29.                 assert(last != NULL);
  30.                 *last = '/';
  31.             }
  32.             scan++;
  33.         }
  34.         fputs(buf, stdout);
  35.     }
  36. }
  37.